/**
  *@File文件:UserAddressService.java
  *@Date日期:2017年7月14日 下午4:24:03
  *@Copyright版权:Corporation 2017
  */
package com.qiaomengapp.serviceImp;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.qiaomengapp.bean.UserAddress;
import com.qiaomengapp.dao.UserAddressMapper;
import com.qiaomengapp.exception.CustomException;
import com.qiaomengapp.service.IUserAddressService;

/**
 *@Description描述:
 *@Author作者 jinxin
 *@Date日期:2017年7月14日
 */
@Service
public class ImpUserAddressService implements IUserAddressService{
	@Autowired
	private UserAddressMapper userAddressMapper;
	
	//添加用户收货地址
	public	int	insertUserAddress(UserAddress userAddress) throws CustomException{
		int i = userAddressMapper.insertUserAddress(userAddress);
		if(i==0){
			throw new CustomException("添加用户收货地址失败");
		}
		return i;
		
	}
		//修改用户收货地址
	public int	updateUserAddress(UserAddress userAddress) throws CustomException{
		int i = userAddressMapper.updateUserAddress(userAddress);
		if(i==0){
			throw new CustomException("修改用户收货地址失败");
		}
		return i;
		
	}
		//删除用户收货地址
	public	int deleteUserAddress(UserAddress userAddress) throws CustomException{
		int i = userAddressMapper.deleteUserAddress(userAddress);
		if(i==0){
			throw new CustomException("删除用户收货地址失败");
		}
		return i;
		
	}
		//查询用户收货地址
	public	List<UserAddress> selectUserAddress(int userId) throws CustomException{
		List<UserAddress> list = userAddressMapper.selectUserAddress(userId);
		if(list==null||list.size()==0){
			throw new CustomException("没有找到用户收货地址");
		}
		return list;
		
	}
	@Override
	public UserAddress selectUserAddressByid(int userAddressId) {
		UserAddress userAddress = userAddressMapper.selectUserAddressByid(userAddressId);
		return userAddress;
	}
	
	
}
